# coding=utf-8
# 代码文件：chapter6/ch6.3.2.py

# import matplotlib.pyplot as plt
# import pandas as pd

import xlwings as xw

app = xw.App(visible=True, add_book=False)

f = r'data\全国总人口10年数据.xls'

wb = app.books.open(f)

sheet1 = wb.sheets.active

rng = sheet1.range('A3:K8')                 # 选择数据源

chartsheet = wb.sheets.add(name='图表工作表', after=sheet1)

chart = chartsheet.charts.add(0, 0)

chart.chart_type = 'cylinder_bar_clustered'  # 设置图表类型

chart.set_source_data(rng)                   # 设置图表数据源

chart.width = 550
chart.height = 450
